var dxdan = new Vue({
  el: '#dxdan',
  data:{
  	type:0,
		farmerId:'',
		fammerName:'',
		des:'',//产品信息ID
		desName:'',//产品信息文字
		companyName:'',
		companyArea:[],
		price:'',
		count:'',
		dxdate:'',
		buyname:'',
		buycontact:''
  },
  mounted:function(){
  	this.fammerName = localStorage.fammername
		this.farmerId = localStorage.fammerid
  },
  methods:{
  	
			switchFormType:function(num){
			this.type = num
		},saveDxdan:function(){
		if(this.des.length<=0){
				mui.alert("请选择产品信息")
				return
			}
	
			if(this.price.length<=0){
				mui.alert("请填写收购价格")
				return
			}
			if(this.count.length<=0){
				mui.alert("请填写收购量")
				return
			}
			if(this.buyname.length<=0){
				mui.alert("请填写下单人姓名")
				return
			}
					if(this.buycontact.length<=0){
				mui.alert("请填写下单人联系方式")
				return
			}
	
			var _this = this
			var areastr = '';	
						for(var i = 0; i < _this.companyArea.length; i++) {
				if(i==0){
					areastr  = _this.companyArea[i]
				}else{
			
					areastr  = areastr +","+ _this.companyArea[i]
				}
						
			}

			plus.nativeUI.showWaiting();
			axios({
				url: sever + '/saveDxdan',
				method: 'POST',
				// 请求体重发送的数据
				params: {
				buyContact:_this.buycontact,buyName:_this.buyname,dxDate:_this.dxdate,price:_this.price,count:_this.count,type:_this.type,farmerId:_this.farmerId,des:_this.des,companyName:_this.companyName,companyArea:areastr
				},
				timeout: 50000,
				// 设置请求头
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).then(function(res){
				plus.nativeUI.closeWaiting(); 
					mui.alert(res.data.message,function(){
						var old_back = mui.back;
						old_back();
					})
			})
		}
  },
});